package com.myidis.controller;

import com.auxiliary.SignalLampCalculator;
import com.auxiliary.SignalLampTimeSequence;
import com.auxiliary.TimeSequence;
import com.myidis.entity.*;
import com.myidis.request.DICalculatorReq;
import com.myidis.request.SLCalculatorReq;
import com.myidis.servlet.SignalIndexCalculatorServlet;
import com.myidis.servlet.SignalLampCalculatorServlet;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

@Controller
@RequestMapping("/SignalIndexCalculate")
@Api(tags = "综合景气指数计算页面接口")
public class SignalIndexCalculateController {

    @Autowired
    SignalIndexCalculatorServlet signalIndexCalculatorServlet;

    @ResponseBody
    @RequestMapping("/list")
    @ApiOperation("计算结果列表调用的接口")
    public ArrayList<IndexResultList> list() {
        return signalIndexCalculatorServlet.all();
    }

    @ResponseBody
    @RequestMapping("/Data")
    @ApiOperation("查看某一条具体计算结果的接口")
    public ArrayList<FullSIResult> data(@RequestBody IndexResultList sea) {
        return signalIndexCalculatorServlet.getData(sea);
    }

    @ResponseBody
    @RequestMapping("/info")
    @ApiOperation("查看某一条计算结果的信息的接口")
    public FullSIResult info(@RequestBody int sea) {
        return signalIndexCalculatorServlet.getInfo(sea);
    }


    @ResponseBody
    @RequestMapping("/Calculate")
    @ApiOperation("计算景气综合指数")
    public ArrayList<TimeSequence> Calculate(@RequestBody SLCalculatorReq req){
        return signalIndexCalculatorServlet.calculate(req);
    }


    @ResponseBody
    @RequestMapping("/del")
    @ApiOperation("删除某一结果的接口")
    public int calculate(@RequestBody int del) {
        return signalIndexCalculatorServlet.delect(del);
    }
}
